//
//  BaseViewController.m
//  InteriorDesign
//
//  Created by lanou on 15/12/16.
//  Copyright (c) 2015年 lanou. All rights reserved.
//

#import "BaseViewController.h"
#import "BrowseViewController.h"
#import "CommunityViewController.h"
#import "ExpertsViewController.h"
#import "InspirationViewController.h"
#import "MyViewController.h"
#import "AppDelegate.h"
@interface BaseViewController ()

@end

@implementation BaseViewController





- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"分类" style:(UIBarButtonItemStyleDone) target:self action:@selector(showMenu)];
    
    
    // Do any additional setup after loading the view.
}

//按钮方法
- (void)showMenu
{
    //懒加载
    if (!_sideMenu) {
        //浏览界面
        RESideMenuItem *browseItem = [[RESideMenuItem alloc] initWithTitle:@"浏览" action:^(RESideMenu *menu, RESideMenuItem *item) {
            [menu hide];
            
            BrowseViewController *browseVC = [[BrowseViewController alloc] init];
            browseVC.title = item.title;
            UINavigationController *navC = [[UINavigationController alloc] initWithRootViewController:browseVC];
            [menu setRootViewController:navC];
        }];
        //灵感界面
        InspirationViewController *inspirationItem = [[RESideMenuItem alloc] initWithTitle:@"灵感" action:^(RESideMenu *menu, RESideMenuItem *item) {
            [menu hide];
            
            InspirationViewController *inspirationVC = [[InspirationViewController alloc] init];
            inspirationVC.title = item.title;
            UINavigationController *navC = [[UINavigationController alloc] initWithRootViewController:inspirationVC];
            [menu setRootViewController:navC];
        }];
        
        //社区界面
        RESideMenuItem *communityItem = [[RESideMenuItem alloc] initWithTitle:@"社区" action:^(RESideMenu *menu, RESideMenuItem *item) {
            [menu hide];
            
            CommunityViewController *communityVC = [[CommunityViewController alloc] init];
            communityVC.title = item.title;
            UINavigationController *navC = [[UINavigationController alloc] initWithRootViewController:communityVC];
            [menu setRootViewController:navC];
        }];
        //专家界面
        RESideMenuItem *expersItem = [[RESideMenuItem alloc] initWithTitle:@"专家" action:^(RESideMenu *menu, RESideMenuItem *item) {
            [menu hide];
        
            ExpertsViewController *expertsVC = [[ExpertsViewController alloc] init];
            //expertsVC.title = item.title;
            UINavigationController *navC = [[UINavigationController alloc] initWithRootViewController:expertsVC];
            [menu setRootViewController:navC];
            }];
        //我的
        RESideMenuItem *myItem = [[RESideMenuItem alloc] initWithTitle:@"我的" action:^(RESideMenu *menu, RESideMenuItem *item) {
            [menu hide];
            
            MyViewController *myVC = [[MyViewController alloc] init];
            myVC.title = item.title;
            UINavigationController *navC = [[UINavigationController alloc] initWithRootViewController:myVC];
            [menu setRootViewController:navC];
        }];
        
        //加入数组
        _sideMenu = [[RESideMenu alloc] initWithItems:@[browseItem,inspirationItem,communityItem,expersItem,myItem]];
        _sideMenu.verticalOffset = IS_WIDESCREEN ? 110 : 76;
        _sideMenu.hideStatusBarArea = [AppDelegate OSVersion] < 6;
    }
    [_sideMenu show];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
